package com.weishi.project.training.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.weishi.project.training.domain.HeartRate;
import com.weishi.project.training.mapper.HeartRateMapper;
import com.weishi.project.training.service.IHeartRateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 心率Service业务层处理
 */
@Service
public class HeartRateServiceImpl extends ServiceImpl<HeartRateMapper, HeartRate> implements IHeartRateService {

    @Autowired
    private HeartRateMapper heartRateMapper;

    /**
     * 查询心率列表
     */
    @Override
    public List<HeartRate> selectHeartRateList(HeartRate heartRate) {
        return heartRateMapper.selectHeartRateList(heartRate);
    }


    /**
     * 查询心率表平均心率
     */
    @Override
    public Integer getAverageHeartRate(Integer userId, Integer trainingDayId, Integer groupId) {
        return heartRateMapper.getAverageHeartRate(userId , trainingDayId , groupId);
    }


    @Override
    public HeartRate qryLastNode(Integer sportsmanId, int groupId, Integer channelId) {
        Map<String,Object> params = new HashMap<>();
        params.put("sportsmanId",sportsmanId);
        params.put("groupId",groupId);
        params.put("channelId",channelId);
        return heartRateMapper.selectLastNode(params);
    }
}